﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuildPlannerLib
{
    // Derived class for resources with a maximum
    public class ResourceWithMaximum : Resource
    {
        // Integer property for maximum amount
        private int maximum;

        public int Maximum
        {
            get { return maximum; }
            set { maximum = value; }
        }

        // Basic constructor
        public ResourceWithMaximum()
        {
            Amount = 0;
            Maximum = 0;
        }

        // Constructor with parameters for starting amount and maximum
        public ResourceWithMaximum(int amount, int maximum)
        {
            Amount = amount;
            Maximum = maximum;
        }

        // Overrides Change() to account for the maximum
        public override void Change(int change)
        {
            Amount = Math.Min(Amount + change, Maximum);
        }
    }
}
